
<%@ page import="forum.Frage"%>
<!DOCTYPE html>
<html>
<head>
<meta name="layout" content="main">
<g:set var="entityName"
	value="${message(code: 'frage.label', default: 'Frage')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>

</head>
<body>
	<%--		<a href="#list-frage" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>--%>
	<%--		<div class="nav" role="navigation">--%>
	<%--			<ul>--%>
	<%--				<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>--%>
	<%--				<li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>--%>
	<%--			</ul>--%>
	<%--		</div>--%>
	<div id="create-frage" class="content scaffold-create" role="main">
			<sec:ifLoggedIn>
		<h1>
			<g:message code="default.create.label" args="[entityName]" />
		</h1>
		<g:if test="${flash.message}">
			<div class="message" role="status">
				${flash.message}
			</div>
		</g:if>
		<g:hasErrors bean="${frageInstance}">
			<ul class="errors" role="alert">
				<g:eachError bean="${frageInstance}" var="error">
					<li
						<g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
							error="${error}" /></li>
				</g:eachError>
			</ul>
		</g:hasErrors>
		<g:form action="save">
			<fieldset class="form">
				<%--					<g:render template="form"/>--%>
				<div
					class="fieldcontain ${hasErrors(bean: frageInstance, field: 'antwort', 'error')} ">
<%--					<label for="antwort"> <g:message code="frage.antwort.label"--%>
<%--							default="Antwort" />--%>
<%----%>
<%--					</label>--%>

<%--					<ul class="one-to-many">--%>
<%--						<g:each in="${frageInstance?.antwort?}" var="a">--%>
<%--							<li><g:link controller="antwort" action="show" id="${a.id}">--%>
<%--									${a?.encodeAsHTML()}--%>
<%--								</g:link></li>--%>
<%--						</g:each>--%>
<%--						<li class="add"><g:link controller="antwort" action="create"--%>
<%--								params="['frage.id': frageInstance?.id]">--%>
<%--								${message(code: 'default.add.label', args: [message(code: 'antwort.label', default: 'Antwort')])}--%>
<%--							</g:link></li>--%>
<%--					</ul>--%>

				</div>

				<div
					class="fieldcontain ${hasErrors(bean: frageInstance, field: 'benutzer', 'error')} required">
					<label for="benutzer" style="visibility:hidden;"> <g:message
							code="frage.benutzer.label" default="Benutzer" /> <span
						class="required-indicator">*</span>
					</label>
					<g:select id="benutzer" name="benutzer.id"
						from="${forum.Benutzer.list()}" optionKey="id" required=""
						value="${frageInstance?.benutzer?.id}" class="many-to-one" style="visibility:hidden;"/>
				</div>

				<div
					class="fieldcontain ${hasErrors(bean: frageInstance, field: 'gestellteFrage', 'error')} ">
					<label for="gestellteFrage"> <g:message
							code="frage.gestellteFrage.label" default="Gestellte Frage" />

					</label>
					<g:textArea name="gestellteFrage"
						value="${frageInstance?.gestellteFrage}" />
				</div>

				<div
					class="fieldcontain ${hasErrors(bean: frageInstance, field: 'kategorie', 'error')} required">
					<label for="kategorie"> <g:message
							code="frage.kategorie.label" default="Kategorie" /> <span
						class="required-indicator">*</span>
					</label>
					<g:select id="kategorie" name="kategorie.id"
						from="${forum.Kategorie.list()}" optionKey="id" required=""
						value="${frageInstance?.kategorie?.id}" class="many-to-one" />
				</div>

			</fieldset>
			<fieldset class="buttons">
				<g:submitButton name="create" class="save"
					value="${message(code: 'default.button.create.label', default: 'Create')}" />
			</fieldset>
		</g:form>
	</div>
	</sec:ifLoggedIn>
	<div id="list-frage" class="content scaffold-list" role="main">
		<h1>
			<g:message code="default.list.label" args="[entityName]" />
		</h1>
		<g:if test="${flash.message}">
			<div class="message" role="status">
				${flash.message}
			</div>
		</g:if>
		<table>
			<thead>
				<tr>

					<th><g:message code="frage.benutzer.label" default="Benutzer" /></th>

					<g:sortableColumn property="dateCreated"
						title="${message(code: 'frage.dateCreated.label', default: 'Date Created')}" />

					<g:sortableColumn property="gestellteFrage"
						title="${message(code: 'frage.gestellteFrage.label', default: 'Gestellte Frage')}" />

					<th><g:message code="frage.kategorie.label"
							default="Kategorie" /></th>

				</tr>
			</thead>
			<tbody>
				<g:each in="${frageInstanceList}" status="i" var="frageInstance">
					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">

						<td><g:link action="show" id="${frageInstance.id}">
								${fieldValue(bean: frageInstance, field: "benutzer")}
							</g:link></td>

						<td><g:formatDate date="${frageInstance.dateCreated}" /></td>

						<td><g:link controller="antwort" id="${frageInstance.id }">
							${fieldValue(bean: frageInstance, field: "gestellteFrage")}</g:link>
						</td>

						<td>
							${fieldValue(bean: frageInstance, field: "kategorie")}
						</td>

					</tr>
				</g:each>
			</tbody>
		</table>
		<div class="pagination">
			<g:paginate total="${frageInstanceTotal}" />
		</div>
	</div>
</body>
</html>
